import java.util.Arrays;
import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Student s1=new Student("张三",18,90);
        Student s2=new Student("李四",20,80);
        Student s3=new Student("王五",20,70);
        Student s4=new Student("赵六",20,60);
        Student s5=new Student("孙七",22,50);
        Student []ss= {s1,s2,s3,s4,s5};
        Arrays.sort(ss,(o1,o2)-> (o1.getHeight()==o2.getHeight())?o1.getAge()-o2.getAge():o1.getHeight() - o2.getHeight());

        // 修改：遍历数组中的每个 Student 对象并分别打印
        for (int i = 0; i < ss.length; i++) {
            System.out.println(ss[i]);
        }

    }
}
